<%@ page language="java" contentType="text/html; charset=UTF-8"
			pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="generateFile.GenerateTxt"%>
<!-- VERIFICA SE O USUÁRIO ESTÁ COM O COOKIE VÁLIDO, SENÃO O REDIRECIONA PARA A PÁGINA DE LOGIN -->
<%@ include file="log/verify_login.jsp" %>

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Criar um Arquivo de Texto</title>
      <link rel="icon" href="favicon.ico" type="image/x-icon" />
      <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
      <link rel="stylesheet" href="menu_madmac_files/cbcscbmenu_madmac.css" type="text/css" />
      <link rel="stylesheet" href="estilos/madmac_tables.css" type="text/css" />
      <link rel="stylesheet" href="estilos/madmac_inputs.css" type="text/css" />
      <script type="text/javascript" src="madmacproject.js"></script>
   </head>
   <body onload="document.getElementById('search_mac').focus()">
      <div class="logotype"><img src="madmac.png" height="120%" alt="MAD MAC"></div>

      <div class="menu_principal">
			<%@ include file="common_pages/menu.jsp" %>
      </div>

      <div class="search_mac">
			<%@include file="common_pages/search_mac.jsp" %>
      </div>

      <div class="corpo">
			<p><br/><br/></p>
			<%

			  String file_name = request.getParameter("file");
			  String delimitador = request.getParameter("delimitador");

			  try {

				  GenerateTxt scriptTxt = GenerateTxt.getInstance();
				  scriptTxt.setArquivo(file_name);
				  scriptTxt.setDelimitador(delimitador);

				  GenerateTxt.getInstance().generateScript(scriptTxt);

			%>
         <table width="70%" align="center" border="1" cellpadding="15" cellspacing="0" rules="rows" class="main_table">
				<tr>
               <td class="cmd_cell"><img src="icons/ok.png" border="0" width="50px" align="middle" alt=""></td>
               <td class="msgOk_cell">Script gerado com sucesso!</td>
				</tr>
         </table>
         <table>
				<tr>
					<td width="5%"></td>
					<td class="meta_cell">Caminho do arquivo</td>
					<td class="data_cell"><%=scriptTxt.getCaminho()%><%=scriptTxt.getArquivo()%></td>
					<td width="5%"></td>
				</tr>
				<tr>
					<td></td>
					<td class="meta_cell">Delimitador utilizado</td>
					<td class="data_cell"><%=scriptTxt.getDelimitador()%></td>
					<td></td>
				</tr>
			</table>
			<%
			} catch (Exception e) {

			%>
         <table width="50%" align="center" border="0" cellpadding="0" cellspacing="0" rules="rows" class="main_table">
				<tr class="alert_cell">
					<td align="center"><img src="icons/file_alert.png" align="middle" width="64px" alt=""></td>
					<td><%=e%></td>
				</tr>
				<tr class="alert_cell">
					<td align="center" colspan="2">
                  <img src="icons/error_back.png" width="54px" align="bottom"
                       title=" Voltar " onclick="javascript:history.go(-1)" style="cursor:pointer" alt="">
               </td>
				</tr>
			</table>
			<%
			  }


			%>
			<p><br/><br/></p>
      </div>
      <div class="footer_madmac">
			<%@include file="common_pages/footer.jsp" %>
      </div>
   </body>
</html>